package com.ychong.ychongwidget.ui

import android.app.Activity
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.ychong.library.data.SelectBean
import com.ychong.library.dialog.BottomListDialog
import com.ychong.library.dialog.ToastDialog
import com.ychong.ychongwidget.R
import com.ychong.ychongwidget.databinding.ActivityBottomListBinding

class BottomListDialogActivity : AppCompatActivity(){
    private var binding: ActivityBottomListBinding? = null

    private var curSelectBean: SelectBean? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = DataBindingUtil.setContentView(this, R.layout.activity_bottom_list)

        binding!!.toastBtn.setOnClickListener{
            showDialog()
        }
    }

    private fun showDialog() {
        val list = ArrayList<SelectBean>()
        list.add(SelectBean("0", "相机", "相机" == curSelectBean?.text))
        list.add(SelectBean("1", "相册", "相册" == curSelectBean?.text))

        BottomListDialog(this)
            .setDataList(list)
            .setSelectListener(object : BottomListDialog.SelectListener {
                override fun select(selectBean: SelectBean) {
                    this@BottomListDialogActivity.curSelectBean = selectBean
                    ToastDialog(this@BottomListDialogActivity).setMsg(selectBean.text).build()
                }

                override fun dismiss() {

                }
            })
            .build()
    }
}